import urllib.request

url = 'http://www.baidu.com'

response = urllib.request.urlopen(url)

print(type(response))

# 按照一个字节一个字节的去读
content = response.read()
print(content)

# 返回多少个字节
content = response.read(5)
print(content)

# 读取一行
content = response.readline()
print(content)

# 读取多行
content = response.readlines()
print(content)

# 返回状态码
print(response.getcode())

print(response.geturl())

# 获取是一个状态信息
print(response.getheaders())


# content = response.read().decode('utf-8')
# print(content)